//package medicalApp.velociraptors.com;

import java.awt.Dimension;
import java.awt.Font;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.SwingConstants;

/**
 * JFrame enclosing the entire application
 * @author Vishnu
 *
 */
@SuppressWarnings("serial")
public class MedAppGUI extends JFrame{
	private MedAppController mac;
	private static JFrame frmWelcome;
	private static FileWriter outFile;
	private static PrintWriter out;
	
	/**
	 * Instantiates a new Controller class and passes itself into that class
	 * Initializes the GUI
	 */
	public MedAppGUI() {
		mac= new MedAppController(this,out);
		frmWelcome = new JFrame();
		initialize();
	}
	
	public static void main(String[] args){
		try {
			outFile = new FileWriter(args[0]);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		out = new PrintWriter(outFile);
		out.println("Log Created");
		@SuppressWarnings("unused")
		MedAppGUI mag = new MedAppGUI();
		frmWelcome.addWindowListener(new WindowListener(){

			@Override
			public void windowActivated(WindowEvent arg0) {
				// TODO Auto-generated method stub
				System.err.println("window activated");
				
			}

			@Override
			public void windowClosed(WindowEvent arg0) {
							
			}

			@Override
			public void windowClosing(WindowEvent arg0) {
				// TODO Auto-generated method stub
				System.out.println("Window closed");
				out.close();	
			}

			@Override
			public void windowDeactivated(WindowEvent arg0) {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void windowDeiconified(WindowEvent arg0) {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void windowIconified(WindowEvent arg0) {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void windowOpened(WindowEvent arg0) {
				// TODO Auto-generated method stub
				
			}
			
		});
		
		
		frmWelcome.setPreferredSize(new Dimension(1024,768));
		frmWelcome.setResizable(false);
		
		frmWelcome.pack();
		frmWelcome.setVisible(true);
	}

	/**
	 * lol
	 * Initialize the frame
	 */
	public void initialize() {
		frmWelcome.setTitle("Welcome!");
		frmWelcome.setResizable(false);
		frmWelcome.setBounds(100,100,1024,768);
		frmWelcome.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frmWelcome.getContentPane().setLayout(null);
		
		
		mac.setLocation(112,131);
		mac.setSize(800,600);
		frmWelcome.getContentPane().add(mac);
		
		JLabel lblWelcomeToThe = new JLabel("Welcome to VelocirAccess Medical 2011");
		lblWelcomeToThe.setHorizontalAlignment(SwingConstants.CENTER);
		lblWelcomeToThe.setFont(new Font("Calibri", Font.PLAIN, 39));
		lblWelcomeToThe.setBounds(10, 11, 998, 109);
		frmWelcome.getContentPane().add(lblWelcomeToThe);
		
	}

	public void exit() {
		
	}
	
}